package com.example.newheze.Current;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.newheze.R;
import com.example.newheze.vo.Show;

import java.util.List;


public class ShowAdapter extends BaseAdapter {

    private List<Show> mData;
    private Context context;
    public ShowAdapter(Context context, List mData){
        this.mData=mData;
        this.context=context;
    }
    //item个数
    public int getCount() {
        return mData.size();
    }

    //根据position获取item的数据
    public Object getItem(int i) {
        return mData.get(i);
    }
    //获取item的id
    public long getItemId(int i) {
        return i;
    }
    //创建列表item的视图
    public View getView(int i, View view, ViewGroup viewGroup) {
        View myview=View.inflate(context, R.layout.currentitem,null);
        Show listViewModel =mData.get(i);
        TextView textView=myview.findViewById(R.id.messages);
        TextView textView2=myview.findViewById(R.id.shuju);
        ImageView showImage = (ImageView) myview.findViewById(R.id.images);
        showImage.setImageResource(listViewModel.getImageId());//为图片视图设置图片资源
        textView.setText(listViewModel.getName());//为文本视图设置文本内容
        textView2.setText(String.valueOf(listViewModel.getAdata()));//为文本视图设置数据内容
        return myview;
    }

}
